<?php
require('config.php');

        $goods_id=$_REQUEST['goods_id'];
		//$goods_id=44;
		$sql="select * from `".$oto."_goods_attributes`,`".$oto."_attributes` where ".$oto."_goods_attributes.goodsId='$goods_id' and isPriceAttr=1 and ".$oto."_goods_attributes.attrId=".$oto."_attributes.attrId order by ".$oto."_attributes.attrId ASC,".$oto."_goods_attributes.isRecomm DESC";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$person_info[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(isset($person_info))
		{
			$attrId_t=-1;
			$t=0;
			$data=array();
			for($i=0;$i<count($person_info);$i++)
			{
				if($person_info[$i]['attrId']!=$attrId_t)
				{
					$attrId_t=$person_info[$i]['attrId'];
					$data[$t]['attrId']=$attrId_t;
					$data[$t]['attrName']=$person_info[$i]['attrName'];
					$t++;
				}
			}
			for($i=0;$i<$t;$i++)
			{
				$t2=0;
				for($j=0;$j<count($person_info);$j++)
				{
					if($data[$i]['attrId']==$person_info[$j]['attrId'])
					{
						$data[$i]['list'][$t2]=$person_info[$j];
						$t2++;
					}
				}
				if($t2==0) $data[$i]['list']=[];
			}
			echo json_encode($data);
		}
		else
		{
			echo '[]';
		}
		
?>